package com.demo;

import java.util.Set;

public class Test {

    public static void main(String[] args) {
        Graph graph = new Graph();

        // 添加节点
        graph.addNode("A");
        graph.addNode("B");
        graph.addNode("C");

        // 添加边
        graph.addEdge("A", "B");
        //graph.addEdge("B", "C");

        // 获取节点的邻居节点
        Set<String> neighbors = graph.getNeighbors("B");
        System.out.println("Neighbors of B: " + neighbors); // 输出：Neighbors of B: [A, C]

        // 判断节点和边是否存在
        boolean hasNodeA = graph.hasNode("A");
        boolean hasEdgeAB = graph.hasEdge("A", "B");
        System.out.println("Has node A: " + hasNodeA); // 输出：Has node A: true
        System.out.println("Has edge A-B: " + hasEdgeAB); // 输出：Has edge A-B: true
    }


    }


